import DList from "@/components/dlist";
import cTitle from "components/title";
export default {
  data() {
    return {
      active: '随意',
      loading: false,
      finished: false,
      info:false,
      page: 1,
      newcomerReward:[],
      vanTab:[{
        title:'全部',
        id:'随意'
      },{
        title:'预计奖励',
        id:4
      },{
        title:'待结算',
        id:1
      },{
        title:'已结算',
        id:2
      },{
        title:'无效奖励',
        id:3
      }]
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getData() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      this.info = true;
      let {data,result,msg} = await $http.post("plugin.newcomer-fission.frontend.controllers.list.index",{page:this.page,record_status:this.active});
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      this.info = false;
      if (data.data.length === 0 || data.data.length < data.per_page || data.current_page === data.last_page) {
        this.finished = true;
      }
      this.newcomerReward.push(...data.data);
      this.page++;
      this.loading = false;
    },
    onLoad(){
      this.info = true;
      this.getData();
    },
    changeTabs(value) {
      this.loading = false;
      this.finished = false;
      this.page = 1;
      this.newcomerReward = [];
      this.getData();
    }
  },
  components: { cTitle , DList}
};